
program chapter5_10
    implicit none
    integer a, n, sn, i, number1, j
    print *, 'sn=a+aa+aaa+...+aaa...a(the number of a is n)'
    print *, 'please input a between 1-9 and n between 1-9'
    read(*, *) a, n
    sn=0
    i=0
    j=1
    number1=1

    do 10, while(i .LT. n)
        sn=sn+a*j ! sn=2 sn=2+2*11=24
        i=i+1 !                          i=1 i=2
        !print *, 'sn=', sn, 'i=', i
        print *,  sn-a*j, '+', a*j, '=', sn

        do 20, while(number1 .LT. i+1) !1<1+1 2<1+1 false done
            j= j+10**(number1) !number1=1+10**1=11  !number1=1+1=2
            number1=number1+1
            !print*, 'how many 1 in this time', j
        20 continue

    10 continue
    print *, sn
end program

